package aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import util.RedisUtil;

@Component
@Aspect
public class ClearCarAspect {
/*测试gitee修改*/

    @Autowired
    RedisUtil redisUtil;


    @Pointcut("execution(* controller.OrderController.createOrder(..))")
    public void myExecution(){

    }

    @AfterReturning(value="myExecution()",returning="result")
    public void afterReturnMethod(JoinPoint joinPoint, Object result){
        if(result.equals("ok")){
            String userName= (String) joinPoint.getArgs()[0];
            System.out.println("userName==>"+userName);

            redisUtil.del(userName);
            System.out.println("删除后"+redisUtil.lGet(userName,0,-1));
        }

    }




}
